package com.itheima.day14.Hashtable.test1;

import java.util.concurrent.ConcurrentHashMap;

public class ConcurrentHashMapTest {
    public static void main(String[] args) throws InterruptedException {
        ConcurrentHashMap<String, String> chm = new ConcurrentHashMap<>();

        new Thread(() -> {
            for (int i = 0; i < 26; i++) {
                chm.put("" + i, "" + i);
            }
        }).start();
        new Thread(() -> {
            for (int i = 26; i < 51; i++) {
                chm.put("" + i, "" + i);
            }
        }).start();

        Thread.sleep(500);
        ConcurrentHashMap.KeySetView<String, String> keys = chm.keySet();
        for (String key : keys) {
            System.out.println(chm.get(key));
        }

    }
}
